# Contributor: Roberto Oliveira <robertoguimaraes8@gmail.com>
# Maintainer: Roberto Oliveira <robertoguimaraes8@gmail.com>
pkgname=lrzip
pkgver=0.651
pkgrel=1
pkgdesc="compression utility that excels at compressing large files"
url="https://github.com/ckolivas/lrzip"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	autoconf
	automake
	bzip2-dev
	libtool
	lz4-dev
	lzo-dev
	zlib-dev
	"
subpackages="$pkgname-doc $pkgname-extra-scripts:extra"
source="$pkgname-$pkgver.tar.gz::https://github.com/ckolivas/lrzip/archive/v$pkgver.tar.gz"

case "$CARCH" in
x86*)
	# not feature detected, so add it here only
	makedepends="$makedepends nasm"
	;;
*)
	;;
esac

# secfixes:
#   0.650-r0:
#     - CVE-2022-28044
#     - CVE-2022-26291
#   0.640-r0:
#     - CVE-2021-27347
#     - CVE-2021-27345
#     - CVE-2020-25467

prepare() {
	default_prepare
	NOCONFIGURE=1 ./autogen.sh
}

build() {
	# compression utility; also doesn't make it any bigger
	CFLAGS="$CFLAGS -O2 -flto" \
	CXXFLAGS="$CXXFLAGS -O2 -flto" \
	LDFLAGS="$LDFLAGS -flto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr
	make
}

check() {
	make check
}

package() {
	make install DESTDIR="$pkgdir"
}

extra() {
	pkgdesc="$pkgdesc (bash scripts)"
	depends="bash $pkgname=$pkgver-r$pkgrel"

	amove usr/bin/lrztar usr/bin/lrzuntar
}

sha512sums="
97671c4705bc06dfd037e38f4384a5ffaf2e3508da217406ac43642b88eae16576818a378bce519812204fecefbd6552a75fc3e74af729ab7b11724b7a6d1998  lrzip-0.651.tar.gz
"
